#ifndef __MIKE_ZHOU_H__
#define __MIKE_ZHOU_H__
#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
 extern "C" {
#endif

#define MZ_STRINGIFY(x) #x
#define MZ_TOSTRING(x) MZ_STRINGIFY(x)

#define MZ_FMIN(a,b) ((a) < (b) ? (a) : (b))
#define MZ_FMAX(a,b) ((a) > (b) ? (a) : (b))

void MZ_Swap16(void * p);
void MZ_Swap32(void * p);
void MZ_Swap64(void * p);

uint8_t MZ_TransASCII2Pack(uint8_t * str, uint8_t * buf, const uint8_t strLen);
uint8_t MZ_TransPack2ASCII(uint8_t * str, uint8_t * buf, const uint8_t strLen);

typedef struct
{
    float sum;
    int num;
    float min;
    float max;
    float avg;
    float delta;
    float m2;       // 二阶中心矩
    float populationVar; // 总体方差
    float sampleVar;      // 样本方差
} MZ_StatResultType;

extern void MZ_StatResultUpdate(MZ_StatResultType* res, float newVal);

typedef struct
{
    float measureNow;
    float resultNow;
    float resultLast;
    float redictionLast;
    float Q;
    float R;
}MZ_KalmanFilterNormalStruct;


MZ_KalmanFilterNormalStruct MZ_KalmanFilterNormalUpdate(MZ_KalmanFilterNormalStruct Stu);

#endif
